import Vue from 'vue'
import Home from '../components/Home.vue'
//import About from '../components/About.vue'
import User from '../components/User.vue'



//导入路由
import Router from 'vue-router'

const About=()=>import('../components/About.vue')

//引入 Home 下面的两个子组件

const HomeMessage =()=>import("../components/HomeMessage.vue")
const HomeNews =()=>import("../components/HomeNews.vue")

// 任何插件，都要使用 vue.use（Router）的方法使用。
Vue.use(Router)

// 把 Router 实例导出。
export default new Router({

//把更改hash 值得写法，更改为 history 的写法， 就没有了 #
  mode: 'history',
  routes: [
    {
      //打开的时候，默认重定向
      path: '',
      redirect: '/home' //重定向
    },
    {
      path: "/user/:userId",
      component: User
    },
    {
      path: "/home",
      component: Home,
      children:[
        {
          path:'',
          redirect:'news'
        },
        {
          path:'news',
          component:HomeNews
        },
        {
          path:'message',
          component:HomeMessage
        }
      ]
    },
    {
      path: "/about",
      component: About
    },
  ]
})
